#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

class STGraph {
private:
	vector<int> segTree;
	size_t n;

	int NOD(int a,int b) {
		if(a * b == 0)
			return max(a,b);
		if (a < b)
			swap(a,b);
		int c;
		while(a % b != 0){
			c = a % b;
			a = b;
			b = c;
		}
		return b;
	}

	void precalc() {
		segTree.resize(n * 2, 0);

		for(int i = n; i < n * 2; ++i)
			segTree[i] = v[i - n];

		for(int i = n - 1; i > 0; i--)
			segTree[i] = NOD(segTree[2 * i],segTree[2 * i + 1]);
	}
    

public:
	vector<int> v;

	A(vector <int>& src) {
		
		n = src.size();
		n = (1 << ((int)(log((double)n - 1)/log(2.0)) + 1));

		v.resize(n);

		for(size_t i = 0; i < src.size(); ++i)
			v[i] = src[i];

		precalc();
	}

	int segNOD(int l, int r) {
		int ans = 0;
		l += n; 
		r += n;
		while(l <= r) {
			if (l & 1)  // Check: is 'left' point at a right son?
				ans = NOD(ans, segTree[l]);
			if (!(r & 1)) // Check: is 'right' point at a left son?
				ans = NOD(ans, segTree[r]);
			l = (l + 1)/2;
			r = (r - 1)/2;
		}
		return ans;
	}
};

int main() {
    vector<int> a, ans;
    int m,n,b,e;

    scanf("%d",&n);
    a.resize(n);

    for(int i = 0; i < n;++i) {
        scanf("%d",&a[i]);
    }

	STGraph SegTree(a);

    scanf("%d",&m);
    ans.resize(m);

    for(int i = 0; i < m; ++i) {
        scanf("%d %d",&b,&e);
		ans[i] = SegTree.segNOD(b,e);
    }
        
    for(int i = 0; i < m; ++i)
        printf("Answer: %d \n",ans[i]);

	system("pause");
    return 0;
}